package com.zzyl.nursing.service.impl;

import java.util.List;
import com.zzyl.common.utils.DateUtils;
import com.zzyl.nursing.dto.VisitRegistrationDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.VisitRegistrationMapper;
import com.zzyl.nursing.domain.VisitRegistration;
import com.zzyl.nursing.service.IVisitRegistrationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;
/**
 * 来访登记Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-28
 */
@Service
public class VisitRegistrationServiceImpl extends ServiceImpl<VisitRegistrationMapper,VisitRegistration> implements IVisitRegistrationService
{
    @Autowired
    private VisitRegistrationMapper visitRegistrationMapper;

    /**
     * 查询来访登记
     * 
     * @param id 来访登记主键
     * @return 来访登记
     */
    @Override
    public VisitRegistration selectVisitRegistrationById(Long id)
    {
        return getById(id);
    }

    /**
     * 查询来访登记列表
     * 
     * @param visitRegistration 来访登记
     * @return 来访登记
     */
    @Override
    public List<VisitRegistration> selectVisitRegistrationList(VisitRegistration visitRegistration)
    {
        return visitRegistrationMapper.selectVisitRegistrationList(visitRegistration);
    }

    /**
     * 新增来访登记
     * 
     * @param visitRegistrationDto 来访登记
     * @return 结果
     */
    @Override
    public int insertVisitRegistration(VisitRegistrationDto visitRegistrationDto)
    {
        VisitRegistration visitRegistration = new VisitRegistration();
        //属性拷贝
        BeanUtils.copyProperties(visitRegistrationDto, visitRegistration);
        //补充创建时间
        visitRegistration.setCreateTime(DateUtils.getNowDate());
        //插入到数据库
        return visitRegistrationMapper.insertVisitRegistration(visitRegistration);

    }

    /**
     * 修改来访登记
     * 
     * @param visitRegistration 来访登记
     * @return 结果
     */
    @Override
    public int updateVisitRegistration(VisitRegistration visitRegistration)
    {
        return updateById(visitRegistration)?1:0;
    }

    /**
     * 批量删除来访登记
     * 
     * @param ids 需要删除的来访登记主键
     * @return 结果
     */
    @Override
    public int deleteVisitRegistrationByIds(Long[] ids)
    {
        return removeByIds(Arrays.asList(ids))?1:0;
    }

    /**
     * 删除来访登记信息
     * 
     * @param id 来访登记主键
     * @return 结果
     */
    @Override
    public int deleteVisitRegistrationById(Long id)
    {
        return removeById(id)?1:0;
    }

    /**
     * 根据来访类型获取来访登记列表
     *
     * @param visitTpe
     */
    @Override
    public List<VisitRegistration> getListByType(Integer visitTpe) {
        return visitRegistrationMapper.getListByType(visitTpe);
    }
}
